home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Windows marzen / Macro ToolsWorks 6.31 / tworks.exe / Samples / Parse full file path to components.mcr < prev    next >
Text File  |  2003-06-10  |  1KB  |  40 lines

  1. <#> 
  2. <#> Parse full file path to drive, directory and file name components
  3. <#> 
  4. <cmds>
  5.  
  6. <var_oper>(vInputFile,"",SELECT_FILE,"Select File","", "0")
  7. <if_str>("_vCanceled==1")<exitmacro><endif>
  8.  
  9. <var_parse>("vInputFile",":\","",vFilePathComponents,vNumOfFilePathComponents)
  10.  
  11. <var_oper>(vNumOfFilePathComponents,"%vNumOfFilePathComponents%-1",CALC_EXPRESSION,"0","", "0")
  12.  
  13. <#> File Name:
  14. <varset>("vOutput_FileName=vFilePathComponents[vNumOfFilePathComponents]","")
  15.  
  16. <var_oper>(vNumOfFilePathComponents,"%vNumOfFilePathComponents%-1",CALC_EXPRESSION,"0","", "0")
  17.  
  18. <#> Drive Letter:
  19. <varset>("vOutput_Drive=vFilePathComponents[0]","")
  20. <var_oper>(vTemp,"%vOutput_Drive%",STR_LENGTH,"","", "0")
  21. <if_num>("vTemp>1")
  22.    <#> This is network path like \\server\directory\,,,\
  23.    <varset>("vOutput_Drive=\\%vOutput_Drive%\","")
  24. <else>
  25.    <#> This is local path like c:\directory\,,,\
  26.    <varset>("vOutput_Drive=%vOutput_Drive%:\","")
  27. <endif>
  28.  
  29. <#> Directory:
  30. <varset>("vOutput_Directory=_vStrEmpty","")
  31.  
  32. <begloop>(vNumOfFilePathComponents)
  33.    <var_oper>(vOutput_Directory,"%vOutput_Directory%",STR_APPEND,"%vFilePathComponents[_vLoopCounter]%\","", "0")
  34. <endloop>
  35.  
  36. <msg>(-100,-100,"Original file: %vInputFile%
  37.  
  38. Drive: %vOutput_Drive%
  39. Directory path: %vOutput_Directory%
  40. File name: %vOutput_FileName%","Message",1)